package com.dom.domweb.modular.controller.sysmger;

import com.dom.common.model.vo.basic.*;
import com.dom.domweb.common.RspModel;
import com.dom.domweb.common.TabPager;
import com.dom.domweb.dao.service.ITGoodVarietyTblService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品品种控制器
 */
@RestController
@RequestMapping("/base")
public class VarietyController {

    @Autowired
    private ITGoodVarietyTblService varietyTblService;

    @RequestMapping("/getVarietyInfoList")
    public TabPager getVarietyInfoList(@RequestParam("limit")int limit, @RequestParam("page")int page){
        B119R request = new B119R();
        request.setPn(page);
        request.setPs(limit == 0 ? 20 : limit);
        B119A result = varietyTblService.getVarietyInfoList(request);
        return new TabPager(result.getVarietyData(),result.getTotalNum());
    }

    @RequestMapping("/getAllVarietyInfo")
    public RspModel getAllVarietyInfo(){
        B119A result = varietyTblService.getAllVarietyInfo();
        return new RspModel(result.getVarietyData());
    }

    @RequestMapping("/getVarietyInfoByCode")
    public RspModel getVarietyInfoByCode(@RequestParam("id") String id){
        B113A result = varietyTblService.getVarietyInfoByCode(id);
        return new RspModel(result);
    }
    @RequestMapping("/insertVarietyInfo")
    public RspModel insertVarietyInfo(@RequestBody B110R request){
        return varietyTblService.insertVarietyInfo(request);
    }

    @RequestMapping("/updateVarietyInfo")
    public RspModel editVarietyInfo(@RequestBody B110R request){
        return varietyTblService.editVarietyInfo(request);
    }

    @RequestMapping("/varietyInfoDel")
    public RspModel varietyInfoDel(@RequestParam("id")String id){
        return varietyTblService.varietyInfoDel(id);
    }
}
